<!doctype html>
<html>
<head>
    <title>{$backend_name}-{$code_name}</title>
    <meta name="description" content="">
    {include file="public/head"}
</head>
<body>
<!--header-->
{include file="public/header"}
<div class="tpl-page-container tpl-page-header-fixed">
    <!--menu-->
    {include file="public/menu"}
    <!--html body-->
    <div class="tpl-content-wrapper">
        <!--nav-->
        <div class="tpl-content-page-title">
            {$code_name}
        </div>
        <ol class="am-breadcrumb">
            <li><a href="{:url('index/index')}" class="am-icon-home">首页</a></li>
            <li class="am-active">{$code_name}</li>
        </ol>
        <!--content-->
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    <span class="am-icon-code"></span> {$code_name}列表
                </div>
                <!--<div class="tpl-portlet-input tpl-fz-ml">
                    <div class="portlet-input input-small input-inline">
                        <div class="input-icon right">
                            <i class="am-icon-search"></i>
                            <input type="text" class="form-control form-control-solid" placeholder="搜索..."></div>
                    </div>
                </div>-->
            </div>
            <div class="tpl-block">
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-12">
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <!--<a href="{:url($code.'/get_new')}" class="am-btn am-btn-default am-btn-success"><span
                                        class="am-icon-plus"></span> 新增
                                </a>
                                <button type="button" class="am-btn am-btn-default am-btn-secondary"><span
                                        class="am-icon-save"></span> 保存
                                </button>
                                <button type="button" class="am-btn am-btn-default am-btn-danger"><span
                                        class="am-icon-trash-o"></span> 删除
                                </button>
                                <button type="button" class="am-btn am-btn-default am-btn-warning to_excel"><span
                                        class="am-icon-archive"></span> 导出Excel
                                </button>-->
                                <select name="dates" style="float: left;margin-right: 10px;">
                                    {foreach name="dates" id="vo"}
                                    <option value="{$key}" {eq name="$selected" value="$key"}selected{/eq}>{$vo}</option>
                                    {/foreach}
                                </select>
                                <input type="date" style="float: left;margin-right: 10px;" value="{$date}" name="date" class="date-picker other"/>
                                <input type="date" style="float: left;margin-right: 10px;" value="{$start_time}" name="start_time" class="date-picker other2"/>
                                <input type="date" style="float: left;margin-right: 10px;" value="{$end_time}" name="end_time" class="date-picker other2"/>
                                <a href="{:url($code.'/index')}" class="am-btn am-btn-primary search_btn">确定</a>
                            </div>
                        </div>
                    </div>
                    <!--<div class="am-u-sm-12 am-u-md-3">
                        <div class="am-form-group">
                            <select data-am-selected="{btnSize: 'sm'}" name="status">
                                <option value="all">所有状态</option>
                            </select>
                        </div>
                    </div>-->
                    <!--<div class="am-u-sm-12 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                            <input type="text" class="am-form-field" name="keywords" value="">
                            <span class="am-input-group-btn">
                                <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search" type="button"></button>
                            </span>
                        </div>
                    </div>-->
                </div>
                <div class="am-g" style="margin-top:20px;">
                    <div id="dashboard">
                        <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
                        {if condition="$report_data"}
                        <div class="portlet-body">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                <tr>
                                    <th class="span3">每个渠道的投票(参与)人</th>
                                    <th>人数</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach name="report_data" id="vo"}
                                <tr><td>{$key}</td><td>{$vo}</td></tr>
                                {/foreach}
                                </tbody>
                            </table>
                        </div>
                        {/if}
                        {if condition="$list"}
                        <div class="portlet-body">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                <tr>
                                    <th class="span3">12小时内得票最多的前{$list|count=###}名</th>
                                    <th>票数</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach name="list" id="item"}
                                <tr>
                                    <td>{$users[$item.participant_id]?:'bug'}</td>
                                    <td>{$item.count}</td>
                                    <td><a href="{:url('vote_list/index',['participant_id'=> $item.participant_id,'active_id'=>$active_id])}"
                                           class="btn mini blue">投票详情</a></td>
                                </tr>
                                {/foreach}
                                </tbody>
                            </table>
                        </div>
                        {/if}
                    </div>
                </div>
            </div>
            <div class="tpl-alert"></div>
        </div>
    </div>
</div>
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">活动地址</div>
        <div class="am-modal-bd">

        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn">确定</span>
        </div>
    </div>
</div>
<!--js-->
{include file="public/js"}
<script src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
<script src="http://cdn.hcharts.cn/highcharts/modules/exporting.js"></script>
<script type="text/javascript">
    $(function () {

        $('.search_btn').click(function(){
            var url = $(this).attr('href');
            var dates = $('select[name=dates]').val();
            var date = $('input[name=date]').val();
            var start_time = $('input[name=start_time]').val();
            var end_time = $('input[name=end_time]').val();
            location.href = url + '?active_id={$active_id}&participant_id={$participant_id}&dates='+dates+
                '&date='+date+'&start_time='+start_time+'&end_time='+end_time;
            return false;
        });

        $('select[name=dates]').change(function(){
            change_date($(this).val());
        });
        change_date('{$selected}');
        function change_date(val){
            if(val == 'other'){
                $('.other').show();
                $('.other2').hide();
            }else if( val == 'other2') {
                $('.other').hide();
                $('.other2').show();
            }else{
                $('.other').hide();
                $('.other2').hide();
            }
        }

        var chart_param = '{$chart}';
        chart_param = JSON.parse(chart_param);
        Highcharts.chart('container', {
            title: {
                text: '活动报表',
                x: -20 //center
            },
            subtitle: {
                text: '数据{if condition="in_array($selected,[7,15,30,'other2'])"}若有缺失天数,请先单独统计该天{/if}',
                x: -20
            },
            xAxis: {
                title: {
                    text: '时间分布'
                },
                categories: chart_param.time
            },
            yAxis: {
                title: {
                    text: '对应数值'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: '人'
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'middle',
                borderWidth: 0
            },
            series: chart_param.series
        });
    });
</script>
</body>
</html>